xlv.obj.markquee={
	extend:function(){
	},
	implement:function(){
	},
	create:function(tag){
		var div=document.createElement((tag||'div'));
		div.setAttribute('xlvobject','xlv.obj.markquee');
		return div;			
	},
	properties:{
		interval:100,
		step:4,
		direction:'left',
		speedx:0,
		speedy:0
	},
	method:{
		construct:function(){
			var style={position:'relative',overflow:'hidden'};
			Element.setStyle(this,style);
			var div;
			this.$V.scroller=div=document.createElement('div');
			div.setAttribute('id', 'xlvid_scroller');
			style={position:'relative'};
			Element.setStyle(div,style);
			while(this.firstChild)div.appendChild(this.firstChild);
			this.appendChild(div);
		},
		initial:function(){
			this.$V.width=this.$V.scroller.offsetWidth;
			Element.addClassName(this,'class_markquee');
			this.$V.pauseFlag=false;
			this.addEventHandler('mouseover', '_mouseover',this.$V.scroller);
			this.addEventHandler('mouseout', '_mouseout',this.$V.scroller);
			var int=this.$P.interval;
			if(Prototype.Browser.IE && int < 300)int=300;
			this.$V.interval=setInterval(this._interval.bind(this),int);
		},
		styleFor:function(element,id){
		},
		_mouseover:function(event){
			this.$V.pauseFlag=true;		
		},
		_mouseout:function(event){
			this.$V.pauseFlag=false;
		},
		_interval:function(){
			var v=this.$V;
			if(!v.pauseFlag && !v.effecting){
				v.effecting=true;
				this.effect();
				v.effecting=false;
			}
		},
		effect:function(){
			var act={left:1, top:1, right:-1, bottom:-1};
			var width=this.$V.scroller.offsetWidth;
			var height=this.$V.scroller.offsetHeight;
			var out_width=this.offsetWidth;
			var out_height=this.offsetHeight;
			var posx = 0;
			try{posx=parseInt(this.$V.scroller.style.left);}catch(e){alert(e);}
			var posy = 0;
			try{posy=parseInt(this.$V.scroller.style.top);}catch(e){alert(e);}
			if(!posx)posx=0;
			if(!posy)posy=0;
			if(!(width>0 && height>0))return;
			if(act[this.$P.direction]){ 			   
			   if(this.$P.direction=='left' || this.$P.direction=='right'){
				   if(posx>=out_width || posx<=width*(-1))
					   posx+=(out_width+width-this.$P.step)*act[this.$P.direction];
			       else posx=(posx-this.$P.step*act[this.$P.direction]);
			       this.$V.scroller.style.left=posx+'px';
			   }else{
			       if(posy>=out_height || posy<=height*(-1))
			    	   posy+=(out_height+height-this.$P.step)*act[this.$P.direction];
			       else posy=(posy-this.$P.step*act[this.$P.direction]);
			       this.$V.scroller.style.top=posy+'px';  			       
			    }     
			}
			if(this.$P.direction=='custom'){
			   if(Math.abs(posx)>=width){  
			      this.$P.speedx*=(-1);
			      posx=posx+this.$P.speedx; 
			   }else posx=posx+this.$P.speedx; 
			   
			   if(Math.abs(posy)>=height){   
			      this.$P.speedy*=(-1);
			      posy=posy+this.$P.speedy;			     
			   }else posy=posy+this.$P.speedy;
			   
			   this.$V.scroller.style.left=posx+'px';
			   this.$V.scroller.style.top=posy+'px';
			}
		}
	}
};
